#include "widget.h"
#include <QGridLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ffmpegThread(new FFmpegThread(this))
    , picture(new QPictureBox(this))
{
    ffmpegThread->open("/home/liujie01/1.mkv");
    ffmpegThread->start();
    connect(ffmpegThread, &FFmpegThread::getOneFrame, this, [=](const QImage &image) {
        picture->setImage(image);
    });

    QGridLayout *layout = new QGridLayout(this);
    layout->addWidget(picture);
    layout->setMargin(0);
    setLayout(layout);

    resize(800, 600);
    setWindowTitle(ffmpegThread->fileName());
}

Widget::~Widget()
{
    ffmpegThread->close();
    ffmpegThread->wait();
}